package com.zbkj.crmeb.task.order;


import com.zbkj.crmeb.chant.service.ChannelPartitionCouponService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import com.utils.DateUtil;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.zbkj.crmeb.store.service.OrderTaskService;

/**
 * 未支付订单，超时系统自动取消订单
 */
@Component
@Configuration //读取配置
public class OrderCancelBySystem {
    private static final Logger logger = LoggerFactory.getLogger(OrderCancelBySystem.class);


    @Autowired
    private OrderTaskService orderTaskService;
    @Autowired
    private ChannelPartitionCouponService channelPartitionCouponService;

    private  static final int overMinutes = 60;

    // 1分钟同步一次数据
    @XxlJob("orderCancelBySystem")
    public void init(){
        logger.info("---OrderCancelBySystem task------produce Data with fixed rate task: Execution Time - {}", DateUtil.nowDateTime());
        try {
            orderTaskService.cancelBySystem(overMinutes);

            // 瓜分券信息检查
            channelPartitionCouponService.cancelBySystem();
        }catch (Exception e){
        	e.printStackTrace();
            logger.error("OrderRefundByUser.task" + " | msg : " + e.getMessage());
        }
    }

}
